﻿using Microsoft.AspNetCore.Mvc;
using studentSubsidy.Entity;
using studentSubsidy.Entity.Message;
using studentSubsidy.Service;

namespace studentSubsidy.Controllers
{
    [ApiController]
    [Route("api/message/[Action]")]
    public class MessageController: Controller
    {
        private MessageService _messageService = new MessageService();
        
        [HttpPost(Name = "sendMessage")]
        public Result SendMessage([FromBody] MessageQuery messageQuery)
        {
            return _messageService.sendMessage(messageQuery);
        }
        
        [HttpGet(Name = "getMessage")]
        public Result GetMessage([FromQuery] int userId)
        {
            return _messageService.getMessageById(userId);
        }
        
        [HttpGet(Name = "updateMessage")]
        public Result UpdateMessage([FromQuery] int userId)
        {
            return _messageService.updateMessage(userId);
        }
    }
}